package examples;

import helpers.IdUniqueHelper;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import data.AutoSiteData;
import debugs.AutoSiteDebug;

import models.AutoSiteModel;

public class CreateData extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException{
		/*String type = (String) request.getParameter("type");
		if (type == null) {
			response.setContentType("text/html");
			response.setCharacterEncoding("UTF-8");
			String txt = "Create example data <br />";
			txt += "----------------------------------------------------------------<br />";
			txt += "<ul>";
			txt += "    <li><a href=\"/examples/create-data?type=autoSite\">Create data example auto Site</a></li>";
			txt += "    <li><a href=\"/examples/create-data?type=user\">Create data example user</a></li>";
			txt += "</ul>";
			response.getWriter().println(txt);
		} else {
			if (type.equalsIgnoreCase("autoSite")) {
				ArrayList<AutoSiteModel> sites = createAutoSite();
				
				for (int i = 0; i < sites.size(); i++) {
					AutoSiteDebug.debug(sites.get(i));
				}
			}
		}*/
	}
	
	private ArrayList<AutoSiteModel> createAutoSite() {
		ArrayList<AutoSiteModel> sites = new ArrayList<AutoSiteModel>();
		
		AutoSiteData autoSiteData = new AutoSiteData();
		AutoSiteModel site = new AutoSiteModel();
		site.setUrl("http://vnexpress.net/");
		site.setRegLink("#content a.link-title");
		site.setRegTitle(".content h1.Title");
		site.setRegContent("#content  .content > div:eq(0)");
		site.setRegRemove("#content  .content .Title, #content  .content .Lead");
		
		autoSiteData.insert(site);
		sites.add(site);
		
		return sites;
	}
}
